package operation;

import book.Book;
import book.BookLIst;

import java.util.NoSuchElementException;
import java.util.Scanner;

public class FindBook implements Ioperation{
    public void work(BookLIst books){
        System.out.println("查找图书");
        System.out.println("请输入你要查找的书籍名称：");
        Scanner sc = new Scanner(System.in);
        String bookName = sc.nextLine();
        int currentSize = books.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            Book temp = books.getBook(i);
            if(temp.getName().equals(bookName)){
                System.out.println("已找到你查找的书 内容如下");
                System.out.println(temp);
                return;
            }
        }
        System.out.println("未找到你要查看的书籍");
    }
}
